package com.isoft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isoft.entity.Permission;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PermissionMapper extends BaseMapper<Permission> {

    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "permissions", column = "id",
                    many = @Many(select = "com.isoft.mapper.PermissionMapper.selectPermissionByPermsissonId"))
    })
    @Select("select * from permission where id=#{permissionId} order by orderId")
    Permission selectPermissionById(Integer permissionId);

    @Select("select * from permission where parentId=#{parentId} order by orderId")
    List<Permission> selectPermissionByPermsissonId(Integer parentId);

}